<?php

class CityGridSearchAPIHandler {

    // property declaration
    public $term;
    public $location;    
    public $response;
    
    const publisher = "10000005010";

    public function __construct($term, $location) {
        $this->term = $term;
        $this->location = $location;
    }

    public function connect() {
        $unsigned_url = "http://api.citygridmedia.com/content/places/v2/search/where" . 
                "?what=" . $this->term .
                "&where=" . $this->location . 
                "&format=json" . 
                "&rpp=5" .
                "&type=restaurant" .
                "&publisher=" . self::publisher;
        $ch = curl_init($unsigned_url);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($ch, CURLOPT_HEADER, 0);
        $data = curl_exec($ch); // Yelp response
        curl_close($ch);
        $response = json_decode($data);
        $this->response = $response;
    }
}

?>
